﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AirlineBooking.Models.DTO
{
    public class DTODocumentType
    {
        static DTODocumentType(){
            using (AirLineDBModelEntities db = new AirLineDBModelEntities())
            {
                AirlineBooking.DocumentType t = db.DocumentTypes.FirstOrDefault(i => i.Name == "Id Card");
                IdCard = t != null ? new DTODocumentType(t) : null;
                t = db.DocumentTypes.FirstOrDefault(i => i.Name == "Passport");
                Passport = t != null ? new DTODocumentType(t) : null;
            }
        }

        private DTODocumentType(int id, string value)
        {
            Id = id;
            Value = value;
        }

        private DTODocumentType(AirlineBooking.DocumentType item)
            : this(item.Id, item.Name)
        {
        }
        public string Value { get; set; }
        public int Id { get; set; }
        public static readonly DTODocumentType IdCard;
        public static readonly DTODocumentType Passport;
    }
}